import *  as userTypes from '../action_types/userTypes'

const initialState = {
    // 用户信息
    user: {},
};
export default function userReducer(state = initialState, action) {
    switch (action.type) {
        // 保存用户信息
        case userTypes.SAVE_USER:
            return {
                ...state,
                user: action.payload.user,
            };
        // 退出登录
        case  userTypes.CLEAR_USER:
            return {
                ...state,
                user: {}
            }
        //   修改用户信息
        case userTypes.MODIFY_USER:
            return {
                ...state,
                user:{
                    ...state.user,
                    ...action.payload.user
                }
            }
        default:
            return state;
    }
}